package com.example.yunxinagyue

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import com.example.yunxinagyue.info_user.MainActivity2

class MineFragment : Fragment(), View.OnClickListener {

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_mine_fragement, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        view.findViewById<ImageView>(R.id.user).setOnClickListener(this)
        view.findViewById<Button>(R.id.favorite).setOnClickListener(this)
    }

    companion object {
        fun newInstance() = MineFragment()
    }

    override fun onClick(p0: View?) {
        when(p0?.id){
            R.id.user -> {
                val intent= Intent(activity, MainActivity2::class.java)
                startActivityForResult(intent,1)
            }
            R.id.favorite -> {
                Logger.info("MineF", "zty - init")
                val intent=Intent(activity,MusicPlayList::class.java).setAction("")
                startActivity(intent)
            }
        }
    }

    override fun startActivityForResult(intent: Intent?, requestCode: Int, options: Bundle?) {
        super.startActivityForResult(intent, requestCode, options)
    }
}